def is_correct_breckets(expr):
    stack = []
    for char in expr:
        if char in ["(", "{", "["]:
            stack.append(char)
        else:
            if not stack:
                return False
            current_char = stack.pop()
            if current_char == "(":
                if char != ")":
                    return False
            if current_char == "{":
                    if char != "}":
                        return False
            if current_char == "[":
                    if char != "]":
                        return False
    if stack:
        return False
    return True

a=input()
if is_correct_breckets(a):
    print("True")
else:
    print("False")
    
